home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / Tools / lynx-2.4 / WWW / Library / Implementation / HTAAServ.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-06-28  |  4.8 KB  |  147 lines

  1. /*                          SERVER SIDE ACCESS AUTHORIZATION MODULE
  2.                                              
  3.    This module is the server side interface to Access Authorization (AA) package. It
  4.    contains code only for server.
  5.    
  6.    Important to know about memory allocation:
  7.    
  8.    Routines in this module use dynamic allocation, but free automatically all the memory
  9.    reserved by them.
  10.    
  11.    Therefore the caller never has to (and never should) free() any object returned by
  12.    these functions.
  13.    
  14.    Therefore also all the strings returned by this package are only valid until the next
  15.    call to the same function is made. This approach is selected, because of the nature of
  16.    access authorization: no string returned by the package needs to be valid longer than
  17.    until the next call.
  18.    
  19.    This also makes it easy to plug the AA package in: you don't have to ponder whether to
  20.    free()something here or is it done somewhere else (because it is always done somewhere
  21.    else).
  22.    
  23.    The strings that the package needs to store are copied so the original strings given as
  24.    parameters to AA functions may be freed or modified with no side effects.
  25.    
  26.    Also note:The AA package does not free() anything else than what it has itself
  27.    allocated.
  28.    
  29.  */
  30.  
  31. #ifndef HTAASERV_H
  32. #define HTAASERV_H
  33.  
  34. #ifndef HTUTILS_H
  35. #include "HTUtils.h"            /* BOOL, PARAMS, ARGS   */
  36. #endif /* HTUTILS_H */
  37. /*#include <stdio.h> included by HTUtils.h -- FM *//* FILE                */
  38. #include "HTRules.h"            /* This module interacts with rule system */
  39. #include "HTAAUtil.h"           /* Common parts of AA   */
  40. #include "HTAuth.h"             /* Authentication       */
  41.  
  42.  
  43. #ifdef SHORT_NAMES
  44. #define HTAAstMs        HTAA_statusMessage
  45. #define HTAAchAu        HTAA_checkAuthorization
  46. #define HTAAcoAH        HTAA_composeAuthHeaders
  47. #define HTAAsLog        HTAA_startLogging
  48. #endif /*SHORT_NAMES*/
  49.  
  50. /*
  51.  
  52. Check Access Authorization
  53.  
  54.    HTAA_checkAuthorization() is the main access authorization function.
  55.    
  56.  */
  57.  
  58. /* PUBLIC                                             HTAA_checkAuthorization()
  59. **              CHECK IF USER IS AUTHORIZED TO ACCESS A FILE
  60. ** ON ENTRY:
  61. **      url             is the document to be accessed.
  62. **      method_name     name of the method, e.g. "GET"
  63. **      scheme_name     authentication scheme name.
  64. **      scheme_specifics authentication string (or other
  65. **                      scheme specific parameters, like
  66. **                      Kerberos-ticket).
  67. **
  68. ** ON EXIT:
  69. **      returns status codes uniform with those of HTTP:
  70. **        200 OK           if file access is ok.
  71. **        401 Unauthorized if user is not authorized to
  72. **                         access the file.
  73. **        403 Forbidden    if there is no entry for the
  74. **                         requested file in the ACL.
  75. **
  76. ** NOTE:
  77. **      This function does not check whether the file
  78. **      exists or not -- so the status  404 Not found
  79. **      must be returned from somewhere else (this is
  80. **      to avoid unnecessary overhead of opening the
  81. **      file twice).
  82. **
  83. */
  84. PUBLIC int HTAA_checkAuthorization PARAMS((CONST char * url,
  85.                                            CONST char * method_name,
  86.                                            CONST char * scheme_name,
  87.                                            char *       scheme_specifics));
  88. /*
  89.  
  90. Compose Status Line Message
  91.  
  92.  */
  93.  
  94. /* SERVER PUBLIC                                        HTAA_statusMessage()
  95. **              RETURN A STRING EXPLAINING ACCESS
  96. **              AUTHORIZATION FAILURE
  97. **              (Can be used in server reply status line
  98. **               with 401/403 replies.)
  99. ** ON EXIT:
  100. **      returns a string containing the error message
  101. **              corresponding to internal HTAAFailReason.
  102. */
  103. PUBLIC char *HTAA_statusMessage NOPARAMS;
  104. /*
  105.  
  106. Compose "Authenticate:" Header Lines for Server Reply
  107.  
  108.  */
  109.  
  110. /* SERVER PUBLIC                                    HTAA_composeAuthHeaders()
  111. **              COMPOSE WWW-Authenticate: HEADER LINES
  112. **              INDICATING VALID AUTHENTICATION SCHEMES
  113. **              FOR THE REQUESTED DOCUMENT
  114. ** ON ENTRY:
  115. **      No parameters, but HTAA_checkAuthorization() must
  116. **      just before have failed because a wrong (or none)
  117. **      authentication scheme was used.
  118. **
  119. ** ON EXIT:
  120. **      returns a buffer containing all the WWW-Authenticate:
  121. **              fields including CRLFs (this buffer is auto-freed).
  122. **              NULL, if authentication won't help in accessing
  123. **              the requested document.
  124. */
  125. PUBLIC char *HTAA_composeAuthHeaders NOPARAMS;
  126. /*
  127.  
  128. Start Access Authorization Logging
  129.  
  130.  */
  131.  
  132. /* PUBLIC                                               HTAA_startLogging()
  133. **              START UP ACCESS AUTHORIZATION LOGGING
  134. ** ON ENTRY:
  135. **      fp      is the open log file.
  136. **
  137. */
  138. PUBLIC void HTAA_startLogging PARAMS((FILE * fp));
  139. /*
  140.  
  141.  */
  142.  
  143. #endif  /* NOT HTAASERV_H */
  144. /*
  145.  
  146.    End of file HTAAServ.h.  */
  147.